#include <math.h>

int maxDistToClosest(int *seats, int seatsSize) {
    int res = 0, l = 0;
    while (l < seatsSize && seats[l] == 0) {
        l++;
    }
    res = fmax(res, l);
    while (l < seatsSize) {
        int r = l + 1;
        while (r < seatsSize && seats[r] == 0) {
            r++;
        }
        if (r == seatsSize) {
            res = fmax(res, r - 1 - l);
        } else {
            res = fmax(res, (r - l) / 2);
        }
        l = r;
    }
    return res;
}

int main() {
    int seats[7] = {1, 0, 0, 0, 1, 0, 1};
    int ret = maxDistToClosest(seats, 7);
    printf("%d", ret);
}